% ^^M% -*- mode: Noweb; noweb-code-mode: TeX-mode -*-
% \iffalse
% Source for FELthesis package (felthesis.dtx)
% Vit Zyka, vit.zyka@seznam.cz
%   2012-10-27 v0.1 first version
%   2013-01-05 v0.2 bibname, otherlanguage*
%   2014-05-04 v0.3 subfigure -> subcaption
%   2014-05-05 v0.4 \AssignmentPage fix
%
%<*driver>
\NeedsTeXFormat{LaTeX2e}[1994/12/01]
\PassOptionsToClass{a4paper}{article}
\documentclass{ltxdoc}
\usepackage{url}
\usepackage[utf8x]{inputenc}
\usepackage[a4paper,height=26cm,hmargin={4cm,1cm}]{geometry}

\def\FelThesis{\textsf{FELthesis}}

\begin{document}
  \OnlyDescription
  \DocInput{felthesis.dtx}
\end{document}
%</driver>
% \fi
% \title{\LaTeX{} Class \FelThesis{} for Thesis at ČVUT FEL} 
% \author{Vít Zýka\\\url{http://zyka.net/typokvitek}\\
%         Prague, Czech Republic}
% \date{\today; v0.2}
% \maketitle
%
% \abstract{\noindent
% This document provides an implementation of officially recommended
% \LaTeX{} design style {\bf template
% of bachelor's (Bsc.), master's (Ing.), or doctoral (Ph.D.) thesis}
% at the Faculty of Electrical
% Engineering of the Czech Technical University in Prague.}
%
% \section{First usage}
% \begin{enumerate}
% \item Install \TeX{} distribution (\TeX{}Live recommended).
% \item Unzip file felthesis.zip into some directory (e.g. thesis).
% \item Run `latex felthesis.ins'.
% \item Make your copy of the file template.tex (e.g. `your-surname-msc.tex').
% \item Test compilation
%   \begin{verbatim}
%   pdflatex your-surname-msc.tex
%   biber your-surname-msc
%   pdflatex your-surname-msc.tex
%   pdflatex your-surname-msc.tex\end{verbatim}
% \item If it runs without errors and \verb+your-surname-msc.pdf+ is
%   generated than your \TeX{} distribution contains all needed packages
%   (see~\ref{sec:dependency}) and you are ready to use the template.
% \end{enumerate}
%
% \section{Dependency}
% \label{dependency}
% \subsection{Class}
% This \FelThesis{} class is based on the scrreprt class from KOMA script
% package. So, all options that are available for scrreprt
% are possible to use for \FelThesis{}.
%
% \subsection{Packages}
% \label{sec:dependency}
% \FelThesis{} class loads the following \LaTeX{} packages
% which must be present at your system:
%\begin{itemize}
% \item babel,
% \item lmodern, cmap,
% \item ifpdf,
% \item xcolor, graphicx,
% \item hyperrref, url,
% \item amsmath, amssymb,
% \item chngcntr, subfigure,
% \item biblatex,
% \item makeidx,
% \item pdfpages. 
%\end{itemize}
% It is supposed that the user has all these packages inslalled on
% his/her \LaTeX{} system.
% 
% ^^M ############################################################# template.tex
% \section{Template, main file}
%    \begin{macrocode}
%<*tpl>
%% FELthesis: LaTeX class for bachelor, master, and phd thesis in CTU FEL
%% template.tex: template file
%% (c) 2012-2014 Vít Zýka, vit.zyka@seznam.cz
%%
%% 2012-12-17 v0.1 first version derived from cmpthesis.tex

\documentclass[bcl,draft]{felthesis} % or [...,czech] for thesis in Czech
%%\documentclass[msc,draft]{felthesis} % or [...,czech] for thesis in Czech
%%\documentclass[phd,draft]{felthesis} % or [...,czech] for thesis in Czech

%% --- your additional packages:
\usepackage[utf8]{inputenc}

%% --- usefull draft packages
%%\usepackage[notref]{showkeys} % show labels for referencies
%%\usepackage{showlabels}       % similar
%%\usepackage{showidx}          % show index entries on every page

%% ======================================================== thesis info
\startThesisInfo
  \Title{thesis title}
  \Author{author name}
  %\AuthorEmail{???@fel.cvut.cz} % optional
  %\ThesisUrl{http://fel.cvut.cz/???/???-bsc.pdf} % optional
  \Date{November 2012}
  \Department{Katedra kybernetiky}
  \Advisor{first advisor, second advisor}
  \KeywordsCz{První klíčové slovo; druhé; třetí; \dots}
  \KeywordsEn{First keyword; second; third; \dots}
  %\AssignmentPage{assignment.pdf} % insert official assignment if given
\stopThesisInfo

%% ============================== your definitions (abbreviations etc.)
%%\def\Ax{\mathbf{A}_{x}}

%% =========================================================== settings
\addbibresource{\jobname.bib} % bibliography file

\graphicspath{{fig}{logo}} % subdirectories where TeX finds pictures

%% ========================================================== text body
\begin{document}

\MakeTitle

\startFrontMatter
  \input{acknowledgement}
  \input{declaration}
  \input{abstract}
  \TableOfContents
  \input{abbreviations}
\stopFrontMatter

\startBodyMatter
  %\includeonly{ch01}
  \include{ch01}
  %\include{ch02}
  %...

  %\startAppendices
  %  \include{app01}
  %\stopAppendices
\stopBodyMatter

\startBackMatter
  \PrintBibliography
  %\PrintIndex % define index entry in the text by: \index{word}
\stopBackMatter

\end{document}

%</tpl>
%    \end{macrocode}
%
% ^^M ###################################################### acknowledgement.tex
% \section{Acknowledgement}
%    \begin{macrocode}
%<*ack>
\startAcknowledgement
Text of acknowledgement\dots
\stopAcknowledgement

%</ack>
%    \end{macrocode}
%
% ^^M ########################################################## declaration.tex
% \section{Declaration}
%    \begin{macrocode}
%<*dec>
\startDeclaration
\ifCzech
  Prohlašuji, že jsem předloženou práci vypracoval samostatně,
  a~že jsem uvedl veškeré použité informační zdroje v~souladu
  s~Metodickým pokynem o~dodržování etických principů při přípravě
  vysokoškolských závěrečných prací.
\fi
\ifEnglish
  I declare that I worked out the presented thesis independently
  and I quoted all used sources of information in accord with
  Methodical instructions about ethical principles for writing
  academic thesis.
\fi
\stopDeclaration

%</dec>
%    \end{macrocode}
%
% ^^M ############################################################# abstract.tex
% \section{Abstract}
%    \begin{macrocode}
%<*abs>
\startAbstractCz
  Text abstraktu česky\dots
\stopAbstractCz

\startAbstractEn
  Text of abstract in English\dots
\stopAbstractEn

%</abs>
%    \end{macrocode}
%
% ^^M ######################################################## abbreviations.tex
% \section{Abbreviation}
%    \begin{macrocode}
%<*abb>
\startAbbreviations{%
  Preliminary text\dots
}
\abbrv[abbrv.]  explanation
\abbrv[...]     ...
\stopAbbreviations

%</abb>
%    \end{macrocode}
%
% ^^M ################################################################# ch01.tex
% \section{Chapter 1}
%    \begin{macrocode}
%<*ch1>
\chapter{Chapter}
Some introductory text\dots

\section{Section}
Another text\dots

%</ch1>
%    \end{macrocode}
%
% ^^M ################################################################ app01.tex
% \section{Appendix 1}
%    \begin{macrocode}
%<*app1>
\chapter{Appendix}
Some introductory text\dots

\section{Section}
Another text\dots

%</app1>
%    \end{macrocode}
%
% ^^M ############################################################# template.bib
% \section{Bibliography template}
%    \begin{macrocode}
%<*bib>
%% FELthesis: LaTeX class for both bachelor, master, and phd thesis
%% template.bib: bibliography file (UTF-8 encoding for biber)
%% (c) 2012 Vit Zyka, vit.zyka at seznam.cz
%%
%% 2012-12-19 v0.1 first version


@ONLINE{ LatinModern,
  TITLE  = {{Latin Modern} font family},
  AUTHOR = {Jackowski, Bogusław and Nowacki, Janusz M.},
  URL    = {http://oldwww.gust.org.pl/projects/e-foundry/latin-modern},
  URLDATE= {2012-12-13},
}

@ARTICLE{ 1,
  TITLE  = {},
  AUTHOR = {},
  JOURNALTITLE  = {},
  YEAR   = {},
%% Optional:
%% translator, annotator, commentator, subtitle, titleaddon, editor,
%% editora, editorb, editorc, journalsubtitle, issuetitle, issuesubtitle, language,
%% origlanguage, series, volume, number, eid, issue, month, pages, version, note, issn,
%% addendum, pubstate, doi, eprint, eprintclass, eprinttype, url, urldate, date
}

@BOOK{ 2,
  TITLE  = {},
  AUTHOR = {},
  YEAR   = {},
%% Optional:
%% editor, editora, editorb, editorc, translator, annotator,
%% commentator, introduction, foreword, afterword, subtitle, titleaddon, maintitle,
%% mainsubtitle, maintitleaddon, language, origlanguage, volume, part, edition,
%% volumes, series, number, note, publisher, location, isbn, chapter, pages, pagetotal,
%% addendum, pubstate, doi, eprint, eprintclass, eprinttype, url, urldate, date
}

@MVBOOK{ 3, % multi-volume book
  TITLE  = {},
  AUTHOR = {},
  YEAR   = {},
%% Optional:
%% editor, editora, editorb, editorc, translator, annotator,
%% commentator, introduction, foreword, afterword, subtitle, titleaddon, language,
%% origlanguage, edition, volumes, series, number, note, publisher, location, isbn,
%% pagetotal, addendum, pubstate, doi, eprint, eprintclass, eprinttype, url, urldate,
%% date
}

@INBOOK{ 4, % part of a book
  TITLE  = {},
  AUTHOR = {},
  BOOKTITLE  = {},
  YEAR   = {},
%% Optional:
%% bookauthor, editor, editora, editorb, editorc, translator,
%% annotator, commentator, introduction, foreword, afterword, subtitle, titleaddon,
%% maintitle, mainsubtitle, maintitleaddon, booksubtitle, booktitleaddon, language,
%% origlanguage, volume, part, edition, volumes, series, number, note, publisher,
%% location, isbn, chapter, pages, addendum, pubstate, doi, eprint, eprintclass,
%% eprinttype, url, urldate, date
}

@BOOKINBOOK{ 5, % book published inside another book
  TITLE  = {},
  AUTHOR = {},
  BOOKTITLE  = {},
  YEAR   = {},
%% Optional:
%% bookauthor, editor, editora, editorb, editorc, translator,
%% annotator, commentator, introduction, foreword, afterword, subtitle, titleaddon,
%% maintitle, mainsubtitle, maintitleaddon, booksubtitle, booktitleaddon, language,
%% origlanguage, volume, part, edition, volumes, series, number, note, publisher,
%% location, isbn, chapter, pages, addendum, pubstate, doi, eprint, eprintclass,
%% eprinttype, url, urldate, date
}

@SUPPBOOK{ 6, % supplemental material in a book
  TITLE  = {},
  AUTHOR = {},
  BOOKTITLE  = {},
  YEAR   = {},
%% Optional:
%% bookauthor, editor, editora, editorb, editorc, translator,
%% annotator, commentator, introduction, foreword, afterword, subtitle, titleaddon,
%% maintitle, mainsubtitle, maintitleaddon, booksubtitle, booktitleaddon, language,
%% origlanguage, volume, part, edition, volumes, series, number, note, publisher,
%% location, isbn, chapter, pages, addendum, pubstate, doi, eprint, eprintclass,
%% eprinttype, url, urldate, date
}

@BOOKLET{ 7, % book-like work without a formal publisher
  TITLE  = {},
  AUTHOR = {},
  YEAR   = {},
%% Optional:
%% subtitle, titleaddon, language, howpublished, type, note, location,
%% chapter, pages, pagetotal, addendum, pubstate, doi, eprint, eprintclass, eprinttype,
%% url, urldate, date
}

@COLLECTION{ 8, % single-volume collection with multiple contributions by distinct authors
  TITLE  = {},
  EDITOR = {},
  YEAR   = {},
%% Optional:
%% editora, editorb, editorc, translator, annotator, commentator,
%% introduction, foreword, afterword, subtitle, titleaddon, maintitle, mainsubtitle,
%% maintitleaddon, language, origlanguage, volume, part, edition, volumes, series,
%% number, note, publisher, location, isbn, chapter, pages, pagetotal, addendum,
%% pubstate, doi, eprint, eprintclass, eprinttype, url, urldate, date
}

@MVCOLLECTION{ 9, % multi-volume collection
  TITLE  = {},
  EDITOR = {},
  YEAR   = {},
%% Optional:
%% editora, editorb, editorc, translator, annotator, commentator,
%% introduction, foreword, afterword, subtitle, titleaddon, language, origlanguage,
%% edition, volumes, series, number, note, publisher, location, isbn, pagetotal,
%% addendum, pubstate, doi, eprint, eprintclass, eprinttype, url, urldate, date
}

@INCOLLECTION{ 10, % contribution to the collection
  TITLE  = {},
  AUTHOR = {},
  BOOKTITLE  = {},
  EDITOR = {},
  YEAR   = {},
%% Optional:
%% editora, editorb, editorc, translator, annotator, commentator,
%% introduction, foreword, afterword, subtitle, titleaddon, maintitle, mainsubtitle,
%% maintitleaddon, booksubtitle, booktitleaddon, language, origlanguage, volume,
%% part, edition, volumes, series, number, note, publisher, location, isbn, chapter,
%% pages, addendum, pubstate, doi, eprint, eprintclass, eprinttype, url, urldate, date
}

@SUPPCOLLECTION{ 11, % supplemental material to the collection
  TITLE  = {},
  AUTHOR = {},
  BOOKTITLE  = {},
  EDITOR = {},
  YEAR   = {},
%% Optional:
%% editora, editorb, editorc, translator, annotator, commentator,
%% introduction, foreword, afterword, subtitle, titleaddon, maintitle, mainsubtitle,
%% maintitleaddon, booksubtitle, booktitleaddon, language, origlanguage, volume,
%% part, edition, volumes, series, number, note, publisher, location, isbn, chapter,
%% pages, addendum, pubstate, doi, eprint, eprintclass, eprinttype, url, urldate, date
}

@MANUAL{ 12, % (technical) documentation
  TITLE  = {},
  AUTHOR = {}, % or editor
  YEAR   = {},
%% Optional:
%% subtitle, titleaddon, language, edition, type, series, number,
%% version, note, organization, publisher, location, isbn, chapter, pages, pagetotal,
%% addendum, pubstate, doi, eprint, eprintclass, eprinttype, url, urldate, date
}

@MISC{ 13, % any other
  TITLE  = {},
  AUTHOR = {}, % or editor
  YEAR   = {},
%% Omissible:
%% author, editor, year
%% Optional:
%% subtitle, titleaddon, language, howpublished, type, version, note,
%% organization, location, date, month, year, addendum, pubstate, doi, eprint,
%% eprintclass, eprinttype, url, urldate
}

@ONLINE{ 14, % online resource
  TITLE  = {},
  AUTHOR = {}, % or editor
  YEAR   = {},
  URL    = {},
%% Omissible:
%% author, editor, year
%% Optional:
%% subtitle, titleaddon, language, version, note, organization, date,
%% month, year, addendum, pubstate, urldate
}

@PATENT{ 15,
  TITLE  = {},
  AUTHOR = {},
  NUMBER = {},
  YEAR   = {},
%% Optional:
%% holder, subtitle, titleaddon, type, version, location, note, date,
%% month, year, addendum, pubstate, doi, eprint, eprintclass, eprinttype, url, urldate
}

@PERIODICAL{ 16, % journal issue
  TITLE  = {},
  EDITOR = {},
  YEAR   = {},
%% Omissible:
%% editor
%% Optional:
%% editora, editorb, editorc, subtitle, issuetitle, issuesubtitle,
%% language, series, volume, number, issue, date, month, year, note, issn, addendum,
%% pubstate, doi, eprint, eprintclass, eprinttype, url, urldate
}

@SUPPPERIODICAL{ 17, % supplemental material to the journal
  TITLE  = {},
  EDITOR = {},
  YEAR   = {},
%% Omissible:
%% editor
%% Optional:
%% author, translator, annotator, commentator, subtitle, titleaddon,
%% editora, editorb, editorc, journalsubtitle, issuetitle, issuesubtitle, language,
%% origlanguage, series, volume, number, eid, issue, month, pages, version, note, issn,
%% addendum, pubstate, doi, eprint, eprintclass, eprinttype, url, urldate, date
}

@PROCEEDINGS{ 18, % single-volume conference proceedings
  TITLE  = {},
  EDITOR = {},
  YEAR   = {},
%% Omissible:
%% editor
%% Optional:
%% subtitle, titleaddon, maintitle, mainsubtitle, maintitleaddon,
%% eventtitle, eventdate, venue, language, volume, part, volumes, series, number, note,
%% organization, publisher, location, month, isbn, chapter, pages, pagetotal, addendum,
%% pubstate, doi, eprint, eprintclass, eprinttype, url, urldate, date
}

@MVPROCEEDINGS{ 19, % multi-volume conference proceedings
  TITLE  = {},
  EDITOR = {},
  YEAR   = {},
%% Omissible:
%% editor
%% Optional:
%% subtitle, titleaddon, eventtitle, eventdate, venue, language,
%% volumes, series, number, note, organization, publisher, location, month, isbn,
%% pagetotal, addendum, pubstate, doi, eprint, eprintclass, eprinttype, url, urldate,
%% date
}

@INPROCEEDINGS{ 20, % article in conference proceedings
  TITLE  = {},
  AUTHOR = {},
  BOOKTITLE  = {},
  EDITOR = {},
  YEAR   = {},
%% Optional:
%% subtitle, titleaddon, maintitle, mainsubtitle, maintitleaddon,
%% booksubtitle, booktitleaddon, eventtitle, eventdate, venue, language, volume, part,
%% volumes, series, number, note, organization, publisher, location, month, isbn,
%% chapter, pages, addendum, pubstate, doi, eprint, eprintclass, eprinttype, url,
%% urldate, date
}

@REFERENCE{ 21, % single-volume reference work like encyclopedia or dictionary
  TITLE  = {},
  EDITOR = {},
  YEAR   = {},
%% Optional:
%% editora, editorb, editorc, translator, annotator, commentator,
%% introduction, foreword, afterword, subtitle, titleaddon, maintitle, mainsubtitle,
%% maintitleaddon, language, origlanguage, volume, part, edition, volumes, series,
%% number, note, publisher, location, isbn, chapter, pages, pagetotal, addendum,
%% pubstate, doi, eprint, eprintclass, eprinttype, url, urldate, date
}

@MVREFERENCE{ 22, % multi-volume reference
  TITLE  = {},
  EDITOR = {},
  YEAR   = {},
%% Optional:
%% editora, editorb, editorc, translator, annotator, commentator,
%% introduction, foreword, afterword, subtitle, titleaddon, language, origlanguage,
%% edition, volumes, series, number, note, publisher, location, isbn, pagetotal,
%% addendum, pubstate, doi, eprint, eprintclass, eprinttype, url, urldate, date
}

@INREFERENCE{ 23, % contribution to the reference
  TITLE  = {},
  AUTHOR = {},
  BOOKTITLE  = {},
  EDITOR = {},
  YEAR   = {},
%% Optional:
%% editora, editorb, editorc, translator, annotator, commentator,
%% introduction, foreword, afterword, subtitle, titleaddon, maintitle, mainsubtitle,
%% maintitleaddon, booksubtitle, booktitleaddon, language, origlanguage, volume,
%% part, edition, volumes, series, number, note, publisher, location, isbn, chapter,
%% pages, addendum, pubstate, doi, eprint, eprintclass, eprinttype, url, urldate, date
}

@REPORT{ 24,
  TITLE  = {},
  AUTHOR = {},
  TYPE  = {},
  INSTITUTION = {},
  YEAR   = {},
%% Optional:
%% subtitle, titleaddon, language, number, version, note, location,
%% month, isrn, chapter, pages, pagetotal, addendum, pubstate, doi, eprint, eprintclass,
%% eprinttype, url, urldate, date
}

@THESIS{ 25,
  TITLE  = {},
  AUTHOR = {},
  TYPE  = {},
  INSTITUTION = {},
  YEAR   = {},
%% Optional:
%% subtitle, titleaddon, language, note, location, month, isbn, chapter,
%% pages, pagetotal, addendum, pubstate, doi, eprint, eprintclass, eprinttype, url,
%% urldate, date
}

@UNPUBLISHED{ 26,
  TITLE  = {},
  AUTHOR = {},
  YEAR   = {},
%% Optional:
%% subtitle, titleaddon, language, howpublished, note, location, isbn,
%% date, month, year, addendum, pubstate, url, urldate
}

%</bib>
%    \end{macrocode}
%
% ^^M ############################################################ felthesis.cls
% \section{Implementation}
%    \begin{macrocode}
%<*cls>
%% FELthesis: LaTeX class for bachelor, master and phd thesis
%% FELthesis.cls: class definition file
%% (c) 2012-2013 Vít Zýka, vit.zyka@seznam.cz
%%
%% 2012-10-27 v0.1 first version derived from CMPthesis
%% 2013-01-05 v0.2 bibname, otherlanguage*
%% 2014-05-04 v0.3 subfigure -> subcaption; no dot at and number; no \sfb warning
%% 2014-05-05 v0.4 \AssignmentPage fix

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{felthesis}[2014/05/05 v0.4 (Vit Zyka)]

\def\FelThesis{\textsf{FELthesis}}
%    \end{macrocode}
%
% ^^M -------------------------------------------------------------------- Misc
% \subsection{General helper macros}
%    \begin{macrocode}
\def\ifEmpty#1{%
  \edef\tmp{#1}%
  \ifx\tmp\empty
}

\def\ifDraft{\ifdim\overfullrule>\z@\relax}

\def\Backslash{$\backslash$}

\long\def\@@expanded{}
\long\def\expanded#1{\long\xdef\@@expanded{\noexpand#1}\@@expanded}
%    \end{macrocode}
%
% ^^M ------------------------------------------------------------ Class options
% \subsection{Class options and parent class}
%    \begin{macrocode}
\newif\ifBcl \Bcltrue
\newif\ifMsc \Mscfalse
\newif\ifPhd \Phdfalse
\newtoks\FelThThesis
\def\defBclThesis{\FelThThesis={\BclName}}
\def\defMscThesis{\FelThThesis={\MscName}}
\def\defPhdThesis{\FelThThesis={\PhdName}}
\defBclThesis

\newif\ifCzech \Czechfalse
\newif\ifSlovak \Slovakfalse
\newif\ifEnglish \Englishtrue

\newif\ifDraft \Draftfalse

\DeclareOption{bcl}{\Bcltrue\Mscfalse\Phdfalse \defBclThesis}
\DeclareOption{msc}{\Bclfalse\Msctrue\Phdfalse \defMscThesis}
\DeclareOption{phd}{\Bclfalse\Mscfalse\Phdtrue \defPhdThesis}
\DeclareOption{czech}{\Czechtrue\Slovakfalse\Englishfalse}
\DeclareOption{slovak}{\Czechfalse\Slovaktrue\Englishfalse}
\DeclareOption{english}{\Czechfalse\Slovakfalse\Englishtrue}
\DeclareOption{draft}{\Drafttrue}

\DeclareOption*{\PassOptionsToClass{\CurrentOption}{scrreprt}}
\ProcessOptions

%% --- load standard KOMA script class
\LoadClass
  [11pt, a4paper, twoside,
   headings=big, abstracton, appendixprefix=true,
   bibliography=totoc, index=totoc,
   cleardoublepage=empty, parskip=false,
   numbers=noenddot]
  {scrreprt}

\RequirePackage[automark]{scrpage2}
%    \end{macrocode}
% ^^M ----------------------------------------------------------------- Geometry
% \subsection{Page geometry}
%    \begin{macrocode}
\typearea[25mm]{14}
\advance\footskip by-\baselineskip
\advance\topmargin by3mm
\columnsep=2em

%\parindent=1.5em
%    \end{macrocode}
%
% ^^M --------------------------------------------------------- Fonts & encoding
% \subsection{Fonts \& encoding}
%    \begin{macrocode}
\RequirePackage{lmodern} % Latin Modern font

\RequirePackage[T1]{fontenc}
\RequirePackage{cmap}
\RequirePackage[utf8]{inputenc}
%    \end{macrocode}
%
% ^^M ----------------------------------------------------------------- Packages
% \subsection{Packages}
% Last babel option set language of option:
%    \begin{macrocode}
\RequirePackage[czech,slovak,english]{babel}
\AtBeginDocument{
  \ifCzech\selectlanguage{czech}\fi
  \ifSlovak\selectlanguage{slovak}\fi
}

\RequirePackage{ifpdf}

% For \verb+graphicx+ package we want set \verb+final+ option, because we use
% \verb+draft+ class option for proof information in the footer and
% want to preserve graphics inclusion.
\ifpdf
  \RequirePackage[pdftex,final]{xcolor,graphicx}
  \definecolor{lgray}{gray}{.9}
  \definecolor{dgreen}{rgb}{0,0.4,0}
  \definecolor{dblue}{rgb}{0,0,0.5}
  \definecolor{dred}{rgb}{0.4,0,0}
\else
  \RequirePackage[final]{xcolor,graphicx}
\fi

\ifpdf
  \usepackage[pdftex,final]{hyperref}
  \hypersetup{colorlinks,pdfhighlight=/O,citecolor=black,unicode=true,
     filecolor=black,urlcolor=black,linkcolor=black,%pagecolor=black,
     breaklinks=true,pdfpagemode=UseNone,plainpages=false,
     %backref=true,pagebackref=true
  }
  %\ifDraft
  %  \hypersetup{citecolor=dgreen,
  %     filecolor=dblue,urlcolor=dblue,linkcolor=dred,%pagecolor=dred,
  %  }
  %\fi
\fi

\RequirePackage[backend=biber,style=numeric,sorting=none]{biblatex}

\RequirePackage{amsmath}
\RequirePackage{amssymb}

% The class scrreprt count figures and tables within a
% chapter. Following lines change this to count them over the whole document.
\RequirePackage{chngcntr}
\counterwithout{figure}{chapter}
\counterwithout{table}{chapter}
\counterwithout{equation}{chapter}

%%\RequirePackage[small]{caption2}
%%  \renewcommand*\captionlabelfont{\sfb}
%%  \renewcommand*\captionlabeldelim{}
%%  %\renewcommand*\captionformat{\ } % does not operate!
%%  \captionindent=\parindent
\addtokomafont{caption}{\small}
\addtokomafont{captionlabel}{\sffamily\bfseries}
\renewcommand*{\captionformat}{~~}
\setcapindent{\parindent}

%\RequirePackage{subfigure}
%  \def\subfigtopskip{5pt}             % subfigure spacing
%  \def\subfigbottomskip{0pt}
%  \def\subfigcapskip{2pt}
%  \def\subfigcapmargin{5pt}
%  \def\thesubfigure{\alph{subfigure}} % subfigure referencing
%  \def\@thesubfigure{{\sffamily\bfseries\thesubfigure)\space}\raggedright}
%  \def\p@subfigure{\thefigure}
\RequirePackage{subcaption}
\captionsetup[sub]{format=plain,indention=1em,
  labelformat=brace,labelfont={small,sf,bf},justification=raggedright}
%  \def\subfigtopskip{5pt}             % subfigure spacing
%  \def\subfigbottomskip{0pt}
%  \def\subfigcapskip{2pt}
%  \def\subfigcapmargin{5pt}
%  \def\thesubfigure{\alph{subfigure}} % subfigure referencing
%  \def\@thesubfigure{{\sffamily\bfseries\thesubfigure)\space}\raggedright}
%  \def\p@subfigure{\thefigure}

\RequirePackage{makeidx}\makeindex
%%\RequirePackage{wrapfig}
%%\RequirePackage{wideenv}
%%\RequirePackage{ifrpage}
\RequirePackage{url}

\RequirePackage[final]{pdfpages} % to include assignment page
%    \end{macrocode}
%
% ^^M ----------------------------------------------------------- LaTeX Settings
% \subsection{Settings}
%    \begin{macrocode}

\iffalse % tty to set \parskip=\baselineskip
\renewcommand*{\chapterheadstartvskip}{\vspace*{2.3\baselineskip}}
\renewcommand*{\chapterheadendvskip}{%
    \vspace{0.725\baselineskip
      \@plus .115\baselineskip \@minus .192\baselineskip}%
}

\renewcommand\section{\@startsection{section}{1}{\z@}%
  {-3.5ex \@plus -1ex \@minus -.2ex}%
  {2.3ex \@plus.2ex}%
  {\ifnum \scr@compatibility>\@nameuse{scr@v@2.96}\relax
    \setlength{\parfillskip}{\z@ plus 1fil}\fi
    \raggedsection\normalfont\sectfont\nobreak\size@section
  }%
}
\renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
  {-3.25ex\@plus -1ex \@minus -.2ex}%
  {1.5ex \@plus .2ex}%
  {\ifnum \scr@compatibility>\@nameuse{scr@v@2.96}\relax
    \setlength{\parfillskip}{\z@ plus 1fil}\fi
    \raggedsection\normalfont\sectfont\nobreak\size@subsection
  }%
}
\renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}%
  {-3.25ex\@plus -1ex \@minus -.2ex}%
  {1.5ex \@plus .2ex}%
  {\ifnum \scr@compatibility>\@nameuse{scr@v@2.96}\relax
    \setlength{\parfillskip}{\z@ plus 1fil}\fi
    \raggedsection\normalfont\sectfont\nobreak\size@subsubsection
  }%
}
\fi
%    \end{macrocode}
%
% ^^M ------------------------------------------------------------------- Labels
% \subsection{Labels}
%    \begin{macrocode}
\def\KeywordsNameCz{Klíčová slova}
\def\KeywordsNameSk{Kĺúčová slová}
\def\KeywordsNameEn{Keywords}

\def\CzLabels{%
  \def\AcknowledgementName{Poděkování}
  \def\DeclarationName{Prohlášení}
  \def\AbstractName{Abstrakt}
  \def\KeywordsName{\KeywordsNameCz}
  \def\AbbrvName{Zkratky}
  \def\TableName{Tab.}
  \def\FigureName{Obr.}
  \def\BclName{bakalářská práce}
  \def\MscName{diplomová práce}
  \def\PhdName{disertační práce}
  \def\AppendicisName{Přílohy}
  \def\bibname{Literatura}
}

\def\SkLabels{%
  \def\AcknowledgementName{Poděkování}
  \def\DeclarationName{Prohlášení}
  \def\AbstractName{Abstrakt}
  \def\KeywordsName{\KeywordsNameSk}
  \def\AbbrvName{Zkratky}
  \def\TableName{Tab.}
  \def\FigureName{Obr.}
  \def\BclName{bakalářská práce}
  \def\MscName{diplomová práce}
  \def\PhdName{disertační práce}
  \def\AppendicisName{Přílohy}
  \def\bibname{Literatúra}
}

\def\EnLabels{%
  \def\AcknowledgementName{Acknowledgement}
  \def\DeclarationName{Declaration}
  \def\AbstractName{Abstract}
  \def\KeywordsName{\KeywordsNameEn}
  \def\AbbrvName{Abbreviations}
  \def\TableName{Tab.}
  \def\FigureName{Fig.}
  \def\BclName{bachelor's thesis}
  \def\MscName{master's thesis}
  \def\PhdName{ph.d. thesis}
  \def\AppendicisName{Appendices}
  \def\bibname{Bibliography}
}

% Some labels must be known before begin document. We define them all.
\def\SchoolCz{České vysoké učení technické v~Praze}
\def\SchoolEn{Czech Technical University in Prague}

\def\FacultyCz{Fakulta elektrotechnická}
\def\FacultyEn{Faculty of Electrical Engineering}

\EnLabels % default

\def\AddToCaption#1{%
  \addto#1{%
    \let\tablename=\TableName
    \let\figurename=\FigureName
  }%
}

\def\AddToCaptions{%
  \AddToCaption\captionsczech
  \AddToCaption\captionsslovak
  \AddToCaption\captionsenglish
}

% The main language is definitely known at begin document. So we
% postpone label setting at this time.
\AtBeginDocument{%
  \ifCzech\CzLabels\fi
  \ifSlovak\SkLabels\fi
  \ifEnglish\EnLabels\fi
  \AddToCaptions
}
%    \end{macrocode}
%
% ^^M -------------------------------------------------- Thesis info & titlepage
% \subsection{Thesis information \& title page}
% \subsubsection{Thesis information}
%
% ^^M ....................................................... Thesis information
%    \begin{macrocode}
\def\startThesisInfo{%
  \bgroup
    \def\Title{\global\FelThTitle}
    %\def\Title{\afterassignment\setStandardTitle\global\FelThTitle}
    %\def\setStandardTitle{\title{\theTitle}}
    \def\Author{\global\FelThAuthor}
    %\def\Author{\afterassignment\setStandardAuthor\global\FelThAuthor}
    %\def\setStandardAuthor{\author{\theAuthor}}
    \def\AuthorEmail{\global\FelThAuthorEmail}
    \def\ThesisUrl{\global\FelThThesisUrl}
    \def\Date{\global\FelThDate}
    \def\Advisor{\global\FelThAdvisor}
    \def\School{\global\FelThSchool}
    \def\Faculty{\global\FelThFaculty}
    \def\Department{\global\FelThDepartment}
    \def\KeywordsCz{\global\FelThKeywordsCz}
    \def\KeywordsEn{\global\FelThKeywordsEn}
    \def\AssignmentPage{\global\FelThAssignmentPage}
    \ifEnglish
      \School{\SchoolEn}\Faculty{\FacultyEn}
    \else
      \School{\SchoolCz}\Faculty{\FacultyCz}
    \fi
}
\def\stopThesisInfo{%
  \egroup
}

\newtoks\FelThTitle
\newtoks\FelThAuthor
\newtoks\FelThAuthorEmail
\newtoks\FelThThesisUrl
\newtoks\FelThDate
\newtoks\FelThAdvisor
\newtoks\FelThSchool
\newtoks\FelThFaculty
\newtoks\FelThDepartment
\newtoks\FelThKeywordsCz
\newtoks\FelThKeywordsEn
\newtoks\FelThAssignmentPage

\def\theTitle{\the\FelThTitle}
\def\theAuthor{\the\FelThAuthor}
\def\theAuthorEmail{\the\FelThAuthorEmail}
\def\theThesis{\the\FelThThesis}
\def\theThesisUrl{\the\FelThThesisUrl}
\def\theDate{\the\FelThDate}
\def\theAdvisor{\the\FelThAdvisor}
\def\theSchool{\the\FelThSchool}
\def\theFaculty{\the\FelThFaculty}
\def\theDepartment{\the\FelThDepartment}
\def\theKeywordsCz{\the\FelThKeywordsCz}
\def\theKeywordsEn{\the\FelThKeywordsEn}
\def\theAssignmentPage{\the\FelThAssignmentPage}

\def\TypeAssignmentPage{%
  \ifEmpty{\theAssignmentPage}\else\includepdf[scale=.8]{\theAssignmentPage}\fi
}

\def\SetPdfCatalogInfo{%
  \ifpdf
    \expanded{%
    \hypersetup{%
      pdftitle={\theTitle},
      pdfauthor={\theAuthor},
      pdfsubject={\theThesis},
      pdfkeywords={\theKeywordsEn},
    }}%
  \fi
}

\AtBeginDocument{\SetPdfCatalogInfo}

\let\Subtitle=\subtitle
%    \end{macrocode}
%
% ^^M ............................................................... Title page
% \subsubsection{Title page}
%    \begin{macrocode}
\def\MakeTitle{\maketitle} % title starts at page #3
\renewcommand*\maketitle[1][1]{%
    \begin{titlepage}
      \setcounter{page}{#1}%
      \let\footnotesize\small
      \let\footnoterule\relax
      \let\footnote\thanks
      \renewcommand*\thefootnote{\@fnsymbol\c@footnote}%
      \let\@oldmakefnmark\@makefnmark
      \renewcommand*{\@makefnmark}{\rlap\@oldmakefnmark}%
      \ifx\@extratitle\@empty \else
        %\noindent\@extratitle\next@tpage\cleardoubleemptypage
        \@extratitle\next@tpage\cleardoubleemptypage
        \thispagestyle{empty}%
      \fi
      \setparsizes{\z@}{\z@}{\z@\@plus 1fil}\par@updaterelative
      \ifx\@titlehead\@empty \else
        \begin{minipage}[t]{\textwidth}%
        \@titlehead
        \end{minipage}\par
      \fi
      \null\vfill
      \begin{center}
        \vskip \z@ \@plus1fill
        \ifx\@subject\@empty \else
          {\subject@font \@subject \par}%
          \vskip 2em
        \fi
        {\titlefont\@title\par}%
        \vskip 1em
        {\ifx\@subtitle\@empty\else\usekomafont{subtitle}\@subtitle\par\fi}%
        \vskip 3em
        {\Large\itshape \lineskip 0.75em
          \begin{tabular}[t]{c}
            \@author
          \end{tabular}\par
        }%
        \vskip \z@ \@plus3fill
        {\Large \@date \par}%
        \vskip \z@ \@plus1fill
        {\Large \@publishers \par}%
        %\vskip 3em
      \end{center}\par
      \vskip-2\baselineskip%\vfill
      \null
    \end{titlepage}
  \setcounter{footnote}{0}%
  \let\thanks\relax
  \let\maketitle\relax
  \let\@maketitle\relax
  \global\let\@thanks\@empty
  \global\let\@author\@empty
  \global\let\@date\@empty
  \global\let\@title\@empty
  \global\let\@subtitle\@empty
  \global\let\@extratitle\@empty
  \global\let\@titlehead\@empty
  \global\let\@subject\@empty
  \global\let\@publishers\@empty
  \global\let\@uppertitleback\@empty
  \global\let\@lowertitleback\@empty
  \global\let\@dedication\@empty
  \global\let\author\relax
  \global\let\title\relax
  \global\let\extratitle\relax
  \global\let\titlehead\relax
  \global\let\subject\relax
  \global\let\publishers\relax
  \global\let\uppertitleback\relax
  \global\let\lowertitleback\relax
  \global\let\dedication\relax
  \global\let\date\relax
  \global\let\and\relax
}%

\AtBeginDocument{
  \titlehead{% top
    %\vskip10\BL
  }
  \subject{\theThesis}
  \title{%
    \theTitle
  }
  \subtitle{}
  \author{\theAuthor}
  \date{%
    \includegraphics[width=4cm]{lev}%
  }
  \publishers{% bottom
        \theDate\\[2\BL]
        \theAdvisor\\[1\BL]
        \theSchool\\[.5ex]
        \theFaculty, \theDepartment\par
  }
}

\setkomafont{title}{%
  \normalfont\normalcolor\sffamily\bfseries\fontsize{20pt}{32pt}\selectfont
}
\setkomafont{subject}{%
  \normalfont\normalcolor\Large\selectfont
}

\extratitle{\TypeAssignmentPage}
%    \end{macrocode}
%
% ^^M ---------------------------------------------------------------- Registers
% \subsection{Useful registers}
%    \begin{macrocode}
\newdimen\tmpd
\newdimen\tmpD
\newdimen\Tmpd
\newdimen\TmpD

\newcount\tmpc
\newcount\tmpC
\newcount\Tmpc
\newcount\TmpC

\newbox\tmpb
\newbox\tmpB
\newbox\Tmpb
\newbox\TmpB
%    \end{macrocode}
%
% ^^M ---------------------------------------------------------- Header & footer
% \subsection{Header \& footer}
%    \begin{macrocode}
\pagestyle{scrheadings}

\def\ProofInfo{}

\ifDraft
  \def\ProofInfo{{\normalfont\ttfamily Draft: \today}}
\fi

\lofoot[\ProofInfo]{\ProofInfo}
\refoot[\ProofInfo]{\ProofInfo}
%    \end{macrocode}
%
% ^^M ------------------------------------------------------ Structural elements
% \subsection{Structural elements}
%    \begin{macrocode}
\def\startFrontMatter{%
  \def\thepage{\roman{page}}
  \pagestyle{scrplain}
}

\def\stopFrontMatter{%
}

\def\startBodyMatter{%
  \cleardoublepage
  \setcounter{page}{1}
  \def\thepage{\arabic{page}}
  \pagestyle{scrheadings}
}

\def\stopBodyMatter{%
}

\def\startBackMatter{%
}

\def\stopBackMatter{%
}

\def\startAppendices{%
  \appendix
  \bgroup
    \let\origwrite=\write
    \def\write{\immediate\origwrite}%
    \addtocontents{toc}{\protect\contentsline{chapter}{\AppendicisName}{}{}}%
  \egroup
}

\def\stopAppendices{%
}
%    \end{macrocode}
%
% ^^M .......................................................... Acknowledgement
% \subsubsection{Acknowledgement}
%    \begin{macrocode}
\def\startAcknowledgement{%
  \cleardoublepage
  \section*{\AcknowledgementName}
}

\def\stopAcknowledgement{%
}
%    \end{macrocode}
% ^^M .............................................................. Declaration
% \subsubsection{Declaration}
%    \begin{macrocode}
\def\startDeclaration{%
  \vfill
  \section*{\DeclarationName}
}

\def\stopDeclaration{%
}
%    \end{macrocode}
%
% ^^M ................................................................. Abstract
% \subsubsection{Abstract}
%    \begin{macrocode}
\def\startAbstractCz{%
  \clearpage
  \bgroup
  %\selectlanguage{czech}
  \begin{otherlanguage*}{czech}
  \section*{\abstractname}
}

\def\stopAbstractCz{%
  \typeKeywords{\KeywordsNameCz}{\theKeywordsCz}
  \par
  \end{otherlanguage*}
  \egroup
}

\def\startAbstractSk{%
  \clearpage
  \bgroup
  %\selectlanguage{slovak}
  \begin{otherlanguage*}{slovak}
  \section*{\abstractname}
}

\def\stopAbstractSk{%
  \typeKeywords{\KeywordsNameSk}{\theKeywordsCz}
  \par
  \end{otherlanguage*}
  \egroup
}

\def\startAbstractEn{%
  \clearpage
  \bgroup
  %\selectlanguage{english}
  \begin{otherlanguage*}{english}
  \section*{\abstractname}
}

\def\stopAbstractEn{%
  \typeKeywords{\KeywordsNameEn}{\theKeywordsEn}
  \par
  \end{otherlanguage*}
  \egroup
}

\def\typeKeywords#1#2{%
  \subsection*{#1}
  #2\par
}
%\selectlanguage{english}
%    \end{macrocode}
%
% ^^M ............................................................ Abbreviations
% \subsubsection{Abbreviations}
%    \begin{macrocode}
\newdimen\AbbrvIndent \AbbrvIndent=7em
\newdimen\AbbrvSep    \AbbrvSep=1em

\def\startAbbreviations{%
  \@ifnextchar*{\bigskip\dostartAbbreviations}{\clearpage\dostartAbbreviations*}%
}
\def\dostartAbbreviations*{%
  \@ifnextchar[{\dodostartAbbreviations}{\dodostartAbbreviations[\AbbrvName]}%
}
\def\dodostartAbbreviations[#1]#2{%
  \section*{#1}
  \ifEmpty{#2}\else#2\par\medskip\fi
  \list{}{\bgroup
    \labelwidth=\z@ \labelsep=\z@
    \leftmargin\AbbrvIndent \itemindent-\leftmargin \setgenlistparam
    \def\makelabel##1{%
      \setbox\Tmpb=\hbox{%
        \normalfont%\sffamily\bfseries
        ##1\hskip\AbbrvSep}%
      \ifdim\wd\Tmpb>\AbbrvIndent\Tmpd=\wd\Tmpb \else\Tmpd=\AbbrvIndent \fi
      \hbox to\Tmpd{\unhbox\Tmpb\hfill}}%
    \let\abbrv\item}
}

\def\stopAbbreviations{%
  \endgraf\egroup\endlist
}
%    \end{macrocode}
%
% ^^M ............................................................. Contents
% \subsubsection{Table of contents}
%    \begin{macrocode}
\setcounter{tocdepth}{3} % content has chapters, sections, and subsections

\def\TableOfContents{\tableofcontents}
\deftocheading{toc}{%
  \clearpage
  \section*{\contentsname}%
  \@mkboth{\contentsname}{\contentsname}%
}
%
% ^^M ............................................................. Bibliography
% \subsubsection{Bibliography}
%    \begin{macrocode}
\def\PrintBibliography{%
  \clearpage
  \addcontentsline{toc}{chapter}{\bibname}
  \printbibliography
}
%    \end{macrocode}
%
% ^^M .................................................................... Index
% \subsubsection{Index}
%    \begin{macrocode}
\def\PrintIndex{%
  \clearpage
  \addcontentsline{toc}{chapter}{\indexname}
  \printindex
}
%    \end{macrocode}
%
% ^^M ............................................................ Figure, table
% \subsubsection{Figure \& table}
%    \begin{macrocode}
\setcounter{topnumber}{10}
\setcounter{bottomnumber}{10}
\setcounter{totalnumber}{10}
\setcounter{dbltopnumber}{10}
\renewcommand{\topfraction}{0.85}
\renewcommand{\bottomfraction}{0.85}
\renewcommand{\dbltopfraction}{0.85}
\renewcommand{\textfraction}{0.1}
\renewcommand{\floatpagefraction}{0.75}
\renewcommand{\dblfloatpagefraction}{0.75}

\setlength\floatsep    {12\p@ \@plus 2\p@ \@minus 2\p@}
\setlength\textfloatsep{16\p@ \@plus 2\p@ \@minus 4\p@}
\setlength\intextsep   {12\p@ \@plus 2\p@ \@minus 2\p@}

\def\HLine{\noalign{\vskip.2em}\hline\noalign{\vskip1ex}}
\def\HHLine{\noalign{\vskip.2em}\hline\hline\noalign{\vskip1ex}}
%    \end{macrocode}
%
% ^^M .................................................................... Lists
% \subsubsection{List redefinition}
%    \begin{macrocode}
\newdimen\GenericParIndent \GenericParIndent=1.5em

\def\setgenlistparam{%
  \setlength{\itemsep}{0pt}\setlength{\parsep}{0pt plus2pt}%
  \setlength{\topsep}{0pt}\setlength{\parskip}{0pt plus2pt}}

%% itemize
\setlength\leftmargini{\parindent}
\def\itemize{%
  \ifnum \@itemdepth >\thr@@\@toodeep\else
    \advance\@itemdepth\@ne
    \edef\@itemitem{labelitem\romannumeral\the\@itemdepth}%
    \expandafter
    \list
      \csname\@itemitem\endcsname
      {\def\makelabel##1{\hss\llap{##1}}%
       \setgenlistparam\setlength\leftmargin{1.5\GenericParIndent}}%
  \fi}

%% enumerate
\def\enumerate{%
  \ifnum \@enumdepth >\thr@@\@toodeep\else
    \advance\@enumdepth\@ne
    \edef\@enumctr{enum\romannumeral\the\@enumdepth}%
      \expandafter
      \list
        \csname label\@enumctr\endcsname
        {\usecounter\@enumctr\def\makelabel##1{\hss\llap{##1}}%
         \setgenlistparam\setlength\leftmargin{1.5\GenericParIndent}}%
  \fi}

%% description
\renewenvironment{description}
  {\list{}{\labelwidth\z@ \itemindent-\leftmargin \setgenlistparam
           \let\makelabel\descriptionlabel}}
  {\endlist}
%    \end{macrocode}
%
% ^^M -------------------------------------------------------------- Definitions
% \subsection{Definitions}
%    \begin{macrocode}
\def\Emph#1{{\sffamily\bfseries#1\/}}

\newdimen\LW \let\LW\linewidth
\newdimen\BL \let\BL\baselineskip

\def\Mref#1{(\ref{#1})}
\def\Fref#1{\FigureName~\ref{#1}}
\def\Tref#1{\TableName~\ref{#1}}
%    \end{macrocode}
%
% ^^M -------------------------------------------------------------------- Final
% \subsection{Final code}
%    \begin{macrocode}
%</cls>
%    \end{macrocode}
% ^^M ##################################################### end of felthesis.cls
% \Finale
% \newpage
% \tableofcontents
%
% ^^M End of file `felthesis.dtx'.
